Skip to content

fix: align ApiException with other SDKs and fix body reading#118

Merged
mridang merged 1 commit intobetafrom
fix/include-root-cause-in-exception-message
Mar 11, 2026
Merged

fix: align ApiException with other SDKs and fix body reading#118
mridang merged 1 commit intobetafrom
fix/include-root-cause-in-exception-message

Conversation

@mridang
Copy link
Copy Markdown
Collaborator

@mridang mridang commented Mar 11, 2026

Closes #113

Description

Aligned ApiException with the Java, Ruby, and Python SDKs by removing the message constructor parameter and building the message internally as "Error <code>". Also removed the redundant getStatusCode() method (callers use inherited getCode() instead) and fixed a bug where the response body was never actually read from the ReadableStream (response?.body?.toString() gave "[object ReadableStream]" instead of the actual body content).

Related Issue

#83

Motivation and Context

The Node SDK's ApiException diverged from the other SDKs in three ways: it took a message parameter instead of building it internally, it had a redundant getStatusCode() accessor, and it never consumed the response body stream. This made the exception less useful for debugging (the body was always "[object ReadableStream]") and inconsistent with the other client libraries.

How Has This Been Tested?

All 36 existing tests pass, including the updated unit test for ApiException and the integration tests that exercise the full request/error path against a real Zitadel instance via Docker Compose.

Documentation:

N/A

Checklist:

  • I have updated the documentation accordingly.
  • I have assigned the correct milestone or created one if non-existent.
  • I have correctly labeled this pull request.
  • I have linked the corresponding issue in this description.
  • I have requested a review from at least 2 reviewers
  • I have checked the base branch of this pull request
  • I have checked my code for any possible security vulnerabilities

@mridang mridang force-pushed the fix/include-root-cause-in-exception-message branch from b35859d to 888a343 Compare March 11, 2026 22:05
@mridang mridang force-pushed the fix/include-root-cause-in-exception-message branch from 888a343 to 39b7eed Compare March 11, 2026 22:26
@mridang mridang self-assigned this Mar 11, 2026
@mridang mridang merged commit cbb4e65 into beta Mar 11, 2026
13 checks passed
github-actions Bot pushed a commit that referenced this pull request Mar 11, 2026
# [4.1.0-beta.16](v4.1.0-beta.15...v4.1.0-beta.16) (2026-03-11)

### Bug Fixes

* align ApiException with other SDKs and fix body reading ([#118](#118)) ([cbb4e65](cbb4e65))
github-actions Bot pushed a commit that referenced this pull request Mar 17, 2026
# [4.1.0](v4.0.0...v4.1.0) (2026-03-17)

### Bug Fixes

* add correct package exports and build for git installs ([#102](#102)) ([f67dcd6](f67dcd6))
* align ApiException with other SDKs and fix body reading ([#118](#118)) ([cbb4e65](cbb4e65))
* correct sed regex in release config to match prerelease suffixes ([f367d08](f367d08))
* **deps:** resolve npm audit vulnerabilities ([5d33e84](5d33e84))
* **deps:** resolve npm audit vulnerabilities ([39c3b10](39c3b10))
* **deps:** resolve npm audit vulnerabilities ([af410bd](af410bd))

### Features

* add TransportOptions for configuring TLS, proxy, and default headers ([#114](#114)) ([b048d51](b048d51))
* configure semantic-release to publish package to GitHub Packages ([c282f98](c282f98))
* **node:** upgrade runtime to Node.js 22, update tooling and dependencies ([783a0ee](783a0ee))
* renamed the package to zitadel/sdk since the other names are reserved. ([eb414bd](eb414bd))
* renamed the package to zitadel/sdk since the other names are reserved. ([724dff9](724dff9))
* **sdk:** generate SDK for version v4.0.0 ([#71](#71)) ([4253292](4253292))
* **sdk:** generate SDK for version v4.1.3 ([#74](#74)) ([3a3a8e7](3a3a8e7))
* **sdk:** generate SDK for version v4.11.0 ([#111](#111)) ([faf8927](faf8927))
* **sdk:** generate SDK for version v4.2.0 ([#75](#75)) ([2bdccb1](2bdccb1))
* **sdk:** generate SDK for version v4.3.0 ([#77](#77)) ([83fc05b](83fc05b))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Runtime errors getting obfuscated

1 participant